# -*- coding: utf-8 -*-

# ------------------------------
# @Time    : 2019/11/14
# @Author  : gao
# @File    : ad_test.py.py
# @Project : AmazingQuant
# ------------------------------

from typing import Union
import AmazingData as ad


if __name__ == '__main__':
    ad.login(username='zdg', password='zdg！2024', host='101.230.159.234', port=8600)
    base_data_object = ad.BaseData()
    code_list = base_data_object.get_code_list(add_market=True, all_code=True)
    sub_data = ad.SubscribeData()


    @sub_data.register(code_list=code_list, period=ad.constant.Period.snapshot.value)
    def onSnapshot(data: Union[ad.constant.SnapshotStock, ad.constant.SnapshotIndex], period):
        print('600000: ', period, data)


    @sub_data.register(code_list=['600007.SH'], period=ad.constant.Period.min1.value)
    def onKline(data: Union[ad.constant.Kline], period):
        print('600007: ', period, data)


    @sub_data.register(code_list=['600008.SH'], period=ad.constant.Period.min3.value)
    def onKline(data: Union[ad.constant.Kline], period):
        print('600008: ', period, data)


    sub_data.run()
